size_t rio_writen(int fd,void *usrbuf,size_t n)                                               
{
size_t nleft = n;
size_t nwritten;
char *bufp = usrbuf;
	   
while(nleft > 0)
{
if((nwritten = write(fd,bufp,nleft))<=0)
{
if(errno == EINTR)  /*Interrupt by sig handler return*/
nread = 0;    /*and call write() again*/
else
return -1;    /*errno set by write()*/
}
nleft -= nwritten;
buft += nwritten;
}
return n;
}